package io.renren.modules.generator.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.annotation.Login;
import io.renren.modules.app.annotation.LoginUser;
import io.renren.modules.app.entity.UserEntity;
import io.renren.modules.generator.entity.TbUserMovieCommentEntity;
import io.renren.modules.generator.service.TbUserMovieCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName : UserMovieCommentController
 * @Description :
 * @Author : Xiaotianyu
 * @Date: 2021-10-13 17:08
 */
@RestController
@RequestMapping("app/user/movie/comment")
@Api("客户端-用户影评管理")
public class UserMovieCommentController {
    @Autowired
    private TbUserMovieCommentService tbUserMovieCommentService;


    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("添加一条影评")
    // @Login
    public R save(@RequestBody TbUserMovieCommentEntity tbUserMovieComment){
        tbUserMovieCommentService.save(tbUserMovieComment);

        return R.ok();
    }

    @GetMapping("/list")
    @ApiOperation("分页查询用户影评")
    @Login
    public R list(@RequestParam Map<String, Object> params,@LoginUser UserEntity user){
        params.put("userId",user.getUserId());
        PageUtils page = tbUserMovieCommentService.queryPage(params);
        return R.ok().put("page", page);
    }
}
